﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace CMS
{
    [Serializable]
    public class Administrations
    {
        public long? ADM_ID { get; set; }
        public string ADM_CODE { get; set; }
        public string ADM_NAME { get; set; }
        public Boolean? ADM_ACTIVE { get; set; }
        public string ADM_COMMENTS { get; set; }
        public DateTime? ADM_DATE { get; set; }

        #region Constructors
        /// <summary>
        /// Creates a new instance of an Page object.
        /// </summary>
        public Administrations() : this(null) { }

        /// <summary>
        /// Creates a new instance of an Page object.
        /// </summary>
        public Administrations(long? id)
        {
            ADM_ID = id;
        }
        #endregion

        /// <summary>
        /// Returns a list of Pages.
        /// </summary>
        public static List<CMS.Administrations> GetAdministration(Int64? ADM_ID, String ADM_CODE, String ADM_NAME, Boolean? ADM_ACTIVE, string ADM_COMMENTS, DateTime? ADM_DATE)
        {
            DataTable StoredProcedureTableAdministrations = CMS.StoredProcedureValues.VW_Administration(ADM_ID, ADM_CODE, ADM_NAME, ADM_ACTIVE, ADM_COMMENTS, ADM_DATE);
            return GetListAdministration(StoredProcedureTableAdministrations);
        }

        /// <summary>
        /// Converts a DataTable into a list of Pages.
        /// </summary>
        public static List<CMS.Administrations> GetListAdministration(DataTable StoredProcedureTable)
        {
            List<CMS.Administrations> OutAdministrations = new List<CMS.Administrations>();

            for (int i = 0; i < StoredProcedureTable.Rows.Count; i++)
            {
                CMS.Administrations Administration = new CMS.Administrations();
                DataRow Row = StoredProcedureTable.Rows[i];

                Administration.ADM_ID = Convert.ToInt64((Row["ADM_ID"]));
                Administration.ADM_NAME = Row["ADM_NAME"].ToString();
                Administration.ADM_CODE = Row["ADM_CODE"].ToString();
                Administration.ADM_ACTIVE = CMS.Functions.NullableBoolean(Row["ADM_ACTIVE"]);
                Administration.ADM_COMMENTS = Row["ADM_COMMENTS"].ToString();
                Administration.ADM_DATE = Convert.ToDateTime(Row["ADM_DATE"].ToString());

                OutAdministrations.Add(Administration);
            }

            return OutAdministrations;
        }
    }
}